package com.enqualcomm.kids.mvp.fillwatchinfo;

import android.content.Context;
import android.media.Image;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.enqualcomm.kids.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Sunzhigang on 2016/7/5.
 */
public class SelectPetTypeRecycleViewAdapter extends RecyclerView.Adapter<SelectPetTypeRecycleViewAdapter.MyViewHolder> {

    private Context context;
    private int[] petImageID = new int[]{
            R.drawable.pet_icon_rabbit,
            R.drawable.pet_icon_alpaca,
            R.drawable.pet_cion_panda,

            R.drawable.pet_icon_bird,
            R.drawable.pet_icon_pony,
            R.drawable.pet_icon_pig,

            R.drawable.pet_icon_tiger,
            R.drawable.pet_icon_lion,
            R.drawable.pet_icon_normal
    };

    private String[] nameString = new String[]{
            context.getString(R.string.pet_name_rabbit),
            context.getString(R.string.pet_name_alpaca),
            context.getString(R.string.pet_name_panda),

            context.getString(R.string.pet_name_bird),
            context.getString(R.string.pet_name_pony),
            context.getString(R.string.pet_name_pig),

            context.getString(R.string.pet_name_tiger),
            context.getString(R.string.pet_name_lion),
            context.getString(R.string.pet_name_normal)
    };

    /**
     * 1-
     * 2-
     * 3-兔子
     * 4-羊驼
     * 5-熊猫
     * 6-小鸡
     * 7-小马
     * 8-小猪
     * 9-老虎
     * 10-狮子
     * 11-通用
     */

    public SelectPetTypeRecycleViewAdapter(Context context) {
        this.context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder viewHolder = new MyViewHolder(LayoutInflater.from(context)
                .inflate(R.layout.select_pet_rv_item, parent, false));
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        holder.imageView.setImageResource(petImageID[position]);
        holder.textView.setText(nameString[position]);
        holder.imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listenr != null) {
                    listenr.clickEvent(position);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return 0;
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView textView;

        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.image_view);
            textView = (TextView) itemView.findViewById(R.id.text_tv);
        }
    }

    private OnImageViewClickListenr listenr;

    public void setImageClickListener(OnImageViewClickListenr listener) {
        this.listenr = listener;
    }

    public interface OnImageViewClickListenr {
        void clickEvent(int i);
    }
}
